package zhengyanze.com.aipoemmax.guide.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * SharedPreferences 工具类
 * 调用该工具类可以很方便的存储
 * 1. Boolean
 * 2. String
 * 等类型的数据 * Created by MrZheng on 2017/6/7.
 */

public class SpUtiles {
    static final String CONFIG = "config";

    /**
     * 存放一个Boolean的数据
     * @param context
     * @param key
     * @param value
     */
    public static void putBoolean(Context context, String key, Boolean value) {
        SharedPreferences sp = context.getSharedPreferences(CONFIG, Context.MODE_PRIVATE);
        SharedPreferences.Editor et = sp.edit();
        et.putBoolean(key, value);
        et.commit();
    }

    public static boolean getBoolean(Context context, String key) {
        SharedPreferences sp = context.getSharedPreferences(CONFIG, Context.MODE_PRIVATE);
        return sp.getBoolean(key,true);
    }
}
